#ifndef LIVERECORDER_H
#define LIVERECORDER_H

#include "libs/extension/extension.h"
#include "liveviewmanager.h"
#include <QDir>
#include <QPointer>
#include <QScopedPointer>

namespace yc {
class Downloader;
struct LiveInfo;
struct Presenter;
}

class GetLiveInfoHelper;
class LiveRecorderView;
class PresenterMonitor;
class RecordTaskManager;

class LiveRecorder : public yc::Extension
{
    Q_OBJECT
public:
    explicit LiveRecorder(yc::ExtensionManager* ext_mgr, QWidget* container);
    ~LiveRecorder();

    LiveViewManager* liveViewManager() const { return live_view_manager_.get(); }
    GetLiveInfoHelper* getLiveInfoHelper() const { return get_live_info_helper_; }
    RecordTaskManager* recordTaskManager() const { return record_task_manager_; }
    PresenterMonitor* monitor() const { return monitor_; }
    QAction* homeAction() const { return home_action_; }
    QAction* autoCheckAction() const { return auto_check_action_; }
    QAction* autoRecordAction() const { return auto_record_action_; }
    QAction* openDirAction() const { return open_dir_action_; }
    QAction* changeCategoryAction() const { return change_category_action_; }
    yc::ExtensionView* view() override;

    bool isRecording() const;
    void changeAttentionAutoCheck(int id, bool auto_check);
    void changeAttentionAutoRecord(int id, bool auto_record);
    void changeAttentionCategory(int id, int category);
    void deleteAttentions(const QList<int>& ids);
    void startRecording(int attention);

    static QDir createAttentionDirectory(int id);
    static bool containsKuaiShouAttentions();

private:
    void onGetAttentions();

    QScopedPointer<LiveViewManager> live_view_manager_;
    GetLiveInfoHelper* get_live_info_helper_;
    RecordTaskManager* record_task_manager_;
    PresenterMonitor* monitor_;
    QPointer<LiveRecorderView> view_;
    QAction* home_action_;
    QAction* auto_check_action_;
    QAction* auto_record_action_;
    QAction* open_dir_action_;
    QAction* change_category_action_;
};

#endif // LIVERECORDER_H
